<?php

add_theme_support( 'post-formats', array( 'status', 'aside', 'gallery', 'video', 'audio' ) );

add_filter("use_block_editor_for_post_type", "disable_gutenberg_editor");
function disable_gutenberg_editor()
{
return false;
}


add_theme_support('post-thumbnails');

add_image_size('product_img', 363, 200, true);



add_image_size('news_img', 460, 330, true);





function dm_strimwidth($str, $start, $width, $trimmarker)
{

  $output = preg_replace('/^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,' . $start . '}((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,' . $width . '}).*/s', '\1', $str);

  return $output . $trimmarker;
}





function get_post_category_id($post_ID)
{

  global $wpdb;

  $sql = "SELECT `term_taxonomy_id` FROM $wpdb->term_relationships WHERE `object_id`='" . $post_ID . "';";

  $cat_id = $wpdb->get_results($sql);

  foreach ($cat_id as $catId) {

    $output = $catId->term_taxonomy_id;
  }

  $myCatId = intval($output); //????????????????ID

  $term = get_term($myCatId, 'taxonomy_name'); //taxonomy_name???????????

  echo $term->name; //???????????????

}





function pagination($query_string)
{

  global $posts_per_page, $paged;

  $my_query = new WP_Query($query_string . "&posts_per_page=-1");

  $total_posts = $my_query->post_count;

  if (empty($paged)) $paged = 1;

  $prev = $paged - 1;

  $next = $paged + 1;

  $range = 3; // only edit this if you want to show more page-links   

  $showitems = ($range * 2) + 1;



  $pages = ceil($total_posts / $posts_per_page);

  $total_posts = $my_query->post_count;



  if ($paged < $pages) {

    echo ("<a href='" . get_pagenum_link($next) . "' class='nextPage'>加载更多文章</a>");
  }
}



function ashuwp_remove_open_sans()
{

  wp_deregister_style('open-sans');

  wp_register_style('open-sans', false);

  wp_enqueue_style('open-sans', '');
}

add_action('init', 'ashuwp_remove_open_sans');
